<?php

namespace app\index\controller;

use app\index\model\PcSoftInfo;
use think\Controller;
use think\Db;
use think\Request;

class Software extends Controller
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
        $banner_list = Db::name('banner')->select();
        $cate_list_all = Db::name('category_soft')->select();
        $request = Request::instance();
        if($request->get('name')){
            $where['Name']      = ['like','%'.$request->get('name').'%'];
        }
        if($request->get('nav')){
            if($request->get('nav') != '9999'){
                $category_id      = $request->get('nav');
                $where['CateId']    = ['=',$category_id];
            }
        }
        $limit            = $request->get('limit','50');
        $where['Status']    = ['=',PcSoftInfo::STATUS_1];
        $where['CateId']    = ['=',1];
//        dump($where);die;
        // 查询分页数据
        $pc_soft_list = Db::name('pc_soft_info')->where($where)->order('id', 'desc')->paginate($limit);

        $host_search_list_6 = Db::name('pc_soft_info')
            ->where($where)
            ->where('hot_search','=',1)
            ->order('OrderBy','desc')
            ->limit(0,6)
            ->select();

        $host_search_list = Db::name('pc_soft_info')
            ->where($where)
            ->where('hot_search','=',1)
            ->order('OrderBy','desc')
            ->limit(0,12)
            ->select();

        $good_evaluation_list = Db::name('pc_soft_info')
            ->where($where)
            ->where('good_evaluation','=',1)
            ->order('OrderBy','DESC')
            ->limit(0,12)
            ->select();

//        dump($host_search_list);die;
//        $this->assign('nav','9999');
        $this->assign('host_search_list_6',$host_search_list_6);
        $this->assign('host_search_list',$host_search_list);
        $this->assign('cate_list_all',$cate_list_all);
        $this->assign('banner_list',$banner_list);
        $this->assign('pc_soft_list',$pc_soft_list);
        $this->assign('good_evaluation_list',$good_evaluation_list);
        return $this->view->fetch();
    }





}
